package rekeningrijden;

import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import util.SnifferDummy;
import util.Sniffer;
import auto.*;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.Popup;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import rekeningrijdenserver.*;
import tijdserver.*;

/**
 *
 * @author roel
 */
public class Main extends JFrame {
    public Main(String name){
        super(name);
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws InterruptedException, NoSuchAlgorithmException, InvalidKeySpecException, IOException {
        TijdServer ts = new TijdServerImpl();
        RekeningRijdenServer rekeningRijdenServer = new RekeningRijdenServerImpl(ts);
        BoordComputer boordComputer = new BoordComputerImpl(ts, rekeningRijdenServer);
        GPS gps = new GPSImpl();
        Sniffer sniffer = new SnifferDummy();
        boordComputer.addSniffer(sniffer);
        ts.addSniffer(sniffer);
        rekeningRijdenServer.addSniffer(sniffer);

        BoordComputerGUI boordComputerGUI = new BoordComputerGUI(ts, rekeningRijdenServer, boordComputer, gps);
        SnifferGUI snifferGUI = new SnifferGUI(sniffer);
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }

        boordComputerGUI.createAndShowGUI();
        snifferGUI.createAndShowGUI();
        boordComputerGUI.toFront();

    }

}

